using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;

namespace CrateManiaPipeline
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content Pipeline
    /// to apply custom processing to content data, converting an object of
    /// type <see cref="TileMapContent"/> to <see cref="TileMapContent"/>.
    /// </summary>
    [ContentProcessor(DisplayName = "Tiled Map Processor")]
    public class TileMapProcessor : ContentProcessor<TileMapContent, TileMapContent>
    {
        public override TileMapContent Process(TileMapContent input, ContentProcessorContext context)
        {
            // actually build the tileset texture
            if ( input.TilesetRef != null )
                input.TilesetRef = context.BuildAsset<TilesetContent, TilesetContent>(input.TilesetRef, "TilesetProcessor");
            if (input.Tileset != null)
                input.Tileset.TilesetImage = context.BuildAsset<Texture2DContent, Texture2DContent>(input.Tileset.TilesetImage, "");
            return input;
        }
    }
}